package net.ming616.pattern.example.factory.simplefactory;

import net.ming616.pattern.example.factory.product.media.audio.APE;
import net.ming616.pattern.example.factory.product.media.audio.Audio;
import net.ming616.pattern.example.factory.product.media.audio.CD;
import net.ming616.pattern.example.factory.product.media.audio.MP3;
import net.ming616.pattern.example.factory.product.media.audio.WAV;

public class AudioSimpleFactory {

	public static Audio getAudio(String audioType) throws Exception {
		Audio audio = null;
		if (audioType.equals("MP3")) {
			audio = new MP3();
		} else if (audioType.equals("WAV")) {
			audio = new WAV();
		} else if (audioType.equals("CD")) {
			audio = new CD();
		} else if (audioType.equals("APE")) {
			audio = new APE();
		} else {
			throw new Exception("unsupported audio format!");
		}
		return audio;
	}
}
